import request from "@/utils/request";
import type {CouponRecordVO, CouponVO, QueryParams, RewardVO} from "@/types/reward";

/** 获取首页优惠券 */
export const getHomePageCouponAPI = () => {
  return request<CouponVO[]>({
    method: "GET",
    url: "/reward/coupon/homePage"
  })
}

/** 领取首页优惠券 */
export const receiveCouponAPI = (couponId: number) => {
  return request<null>({
    method: "POST",
    url: "/reward/coupon//receive/" + couponId
  })
}

/** 获取未使用优惠券 */
export const getUnusedCouponAPI = () => {
  return request<CouponRecordVO[]>({
    method: "GET",
    url: "/reward/coupon/unused"
  })
}

/** 分页获取已失效优惠券 */
export const getInvalidCouponByPageAPI = (data: QueryParams) => {
  return request<CouponRecordVO[]>({
    method: "GET",
    url: "/reward/coupon/invalid",
    data
  })
}

/** 获取未使用优惠券 */
export const getCanUseCouponByAmountAPI = (amount: string) => {
  return request<CouponRecordVO[]>({
    method: "GET",
    url: "/reward/coupon/canUse/" + amount
  })
}

/** 获取奖励信息 */
export const getRewardInfoAPI = () => {
  return request<RewardVO[]>({
    method: "GET",
    url: "/reward/reward"
  })
}
